home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c,comp.lang.c++
- Path: newsfeed.internetmci.com!miwok!linex1!news
- From: mfried@linex.com (Marty Fried)
- Subject: Re: Q:Hex to Decimal?
- X-Nntp-Posting-Host: sp100.linex.com
- Message-ID: <3170908a.11774229@news.linex.com>
- Sender: news@linex1.linex.com
- Organization: Cirrius Cybernetics Corp
- X-Newsreader: Forte Agent .99e/32.209
- References: <316D2289.4759@tricon.net>
- Date: Sun, 14 Apr 1996 05:50:20 GMT
-
- Once upon a time (OK, it was Thu, 11 Apr 1996 11:17:29 -0400), Thomas
- A Cooper <tacooper@tricon.net> wrote:
-
- >I saw in a magazine a simple function to convert a HEX string to an
- >integer:
- >
- >long int FAR PASCAL hex2int(char far *s)
- >{
- > return strtol(s,NULL,16);
- >}
- >
- > I'm struggling with the reverse situation, a function to convert an
- >integer into a HEX string. Anybody got any ideas?? Thanks in advance for
- >your help.
-
- Have you tried something like:
- void int2hex(LPSTR s, int num)
- {
- sprintf(s, "%x", num);
- )
-
- I guess there's a C++ stream class you could use, but I haven't gotten
- around to learning that yet.
-
-
- _______________________________________________________
- Marty Fried - mfried@linex.com Press Enter to Exit
- San Anselmo, CA -NT message
- (MSVC4 + MFC) && (Win95 || NT);
-